# note/models.py
from datetime import datetime

from django.db import models
from operation.models import LabelProfile
from users.models import UserProfile

# Create your models here.
class NoteProfile(models.Model):
    userprofile_id = models.ForeignKey(UserProfile,verbose_name='用户信息',on_delete=models.CASCADE)
    note_title = models.CharField("笔记标题", max_length=50)
    note_content = models.TextField('笔记内容')
    note_label = models.ManyToManyField(LabelProfile)
    create_saved = models.DateTimeField("创建时间", default=datetime.now)
    last_saved = models.DateTimeField("最后一次保存时间", default=datetime.now)
    note_collected_num = models.IntegerField("收藏次数", default=0)
    note_reading_quantity = models.IntegerField("阅读量",default=0)
    note_shared_num = models.IntegerField("分享次数", default=0)
    note_agreed_num = models.IntegerField("点赞次数", default=0)
    note_opposed_num = models.IntegerField("反对数量", default=0)
    note_commented_num = models.IntegerField("评论数量", default=0)
    note_informed_num = models.IntegerField("举报次数", default=0)
    is_published = models.BooleanField('是否发布', default=False)

    class Meta:
        verbose_name = "笔记"
        verbose_name_plural = verbose_name


class note_comment_profile(models.Model):
    userprofile_id = models.ForeignKey(UserProfile, related_name="note_comment", verbose_name='用户信息', on_delete=models.CASCADE)
    note_comment_userprofile_id = models.ForeignKey(UserProfile, related_name="note_respect", verbose_name='评论对象', null=True, on_delete=models.CASCADE)
    note_id = models.ForeignKey(NoteProfile, verbose_name='笔记', on_delete=models.CASCADE)
    note_comment_content = models.CharField('评论内容',max_length=200)
    note_comment_agreed_num = models.IntegerField("点赞次数", default=0)
    note_comment_opposed_num = models.IntegerField("举报次数", default=0)
    note_comment_published_time = models.DateTimeField("发表时间", default=datetime.now)

    class Meta:
        verbose_name = '笔记评论'
        verbose_name_plural = verbose_name

